]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
NetworkMenu: make the settings launcher point to the right devices
authorGiovanni Campagna <gcampagna@src.gnome.org>
Wed, 2 Oct 2013 17:39:58 +0000 (19:39 +0200)
committerGiovanni Campagna <gcampagna@src.gnome.org>
Wed, 9 Oct 2013 16:39:44 +0000 (18:39 +0200)
Tell gnome-control-center to focus on the associated device when
launching it from one of the submenus.

https://bugzilla.gnome.org/show_bug.cgi?id=709246

js/misc/util.js
js/ui/status/network.js

index 9e8dfa4efde5e98c557d2b426203732787c13380..6ffda1e1ab412d5db74a9d82d589f4e4fccf4ad0 100644 (file)
@@ -1,6 +1,7 @@
 // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
 
 const Clutter = imports.gi.Clutter;
+const Gio = imports.gi.Gio;
 const GLib = imports.gi.GLib;
 const Lang = imports.lang;
 const St = imports.gi.St;
@@ -79,6 +80,22 @@ function spawnCommandLine(command_line) {
     }
 }
 
+// spawnApp:
+// @argv: an argv array
+//
+// Runs @argv as if it was an application, handling startup notification
+function spawnApp(argv) {
+    try {
+        let app = Gio.AppInfo.create_from_commandline(argv.join(' '), null,
+                                                      Gio.AppInfoCreateFlags.SUPPORTS_STARTUP_NOTIFICATION);
+
+        let context = global.create_app_launch_context();
+        app.launch([], context);
+    } catch(err) {
+        _handleSpawnError(argv[0], err);
+    }
+}
+
 // trySpawn:
 // @argv: an argv array
 //
index 10b3d342f850d1b8c4bb449c19cee751c8cd2cc5..d8b896c6ff01a5a4b0c8b6ccec8426cdd0959ae7 100644 (file)
@@ -83,6 +83,17 @@ function ensureActiveConnectionProps(active, settings) {
     }
 }
 
+function createSettingsAction(label, device) {
+    let item = new PopupMenu.PopupMenuItem(label);
+
+    item.connect('activate', function() {
+        Util.spawnApp(['gnome-control-center', 'network', 'show-device',
+                       device.get_path()]);
+    });
+
+    return item;
+}
+
 const NMConnectionItem = new Lang.Class({
     Name: 'NMConnectionItem',
 
@@ -283,7 +294,6 @@ const NMConnectionDevice = new Lang.Class({
         this._settings = settings;
 
         this._autoConnectItem = this.item.menu.addAction(_("Connect"), Lang.bind(this, this._autoConnect));
-        this.item.menu.addSettingsAction(_("Network Settings"), 'gnome-network-panel.desktop');
 
         this._stateChangedId = this._device.connect('state-changed', Lang.bind(this, this._deviceStateChanged));
         this._activeConnectionChangedId = this._device.connect('notify::active-connection', Lang.bind(this, this._activeConnectionChanged));
@@ -413,6 +423,9 @@ const NMDeviceModem = new Lang.Class({
 
     _init: function(client, device, settings) {
         this.parent(client, device, settings);
+
+        this.item.menu.addMenuItem(createSettingsAction(_("Mobile Broadband Settings"), device));
+
         this._mobileDevice = null;
 
         let capabilities = device.current_capabilities;
@@ -494,6 +507,12 @@ const NMDeviceBluetooth = new Lang.Class({
     Extends: NMConnectionDevice,
     category: NMConnectionCategory.WWAN,
 
+    _init: function(client, device, settings) {
+        this.parent(client, device, settings);
+
+        this.item.menu.addMenuItem(createSettingsAction(_("Mobile Broadband Settings"), device));
+    },
+
     _autoConnect: function() {
         // FIXME: DUN devices are configured like modems, so
         // We need to spawn the mobile wizard
@@ -975,7 +994,7 @@ const NMDeviceWireless = new Lang.Class({
         this._toggleItem.connect('activate', Lang.bind(this, this._toggleWifi));
         this.item.menu.addMenuItem(this._toggleItem);
 
-        this.item.menu.addSettingsAction(_("Network Settings"), 'gnome-network-panel.desktop');
+        this.item.menu.addMenuItem(createSettingsAction(_("Wi-Fi Settings"), device));
 
         this._wirelessEnabledChangedId = this._client.connect('notify::wireless-enabled', Lang.bind(this, this._sync));
         this._wirelessHwEnabledChangedId = this._client.connect('notify::wireless-hardware-enabled', Lang.bind(this, this._sync));